package com.yty.order.entity;

import com.yty.order.form.OrderDetailForm;
import com.yty.product.apidata.ProductInfoOutput;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class OrderDetail {
    private Long id;

    private String detailId;

    private String orderId;

    private String productId;

    private String productName;

    private BigDecimal productPrice;

    private Integer productQuantity;

    private String productIcon;

    private Date createTime;

    private Date updateTime;

    /**
     * 填充商品信息
     *
     * @param productInfoOutput
     * @return
     */
    public OrderDetail fillByProductInfoOutput(ProductInfoOutput productInfoOutput) {
        productName = productInfoOutput.getProductName();
        productPrice = productInfoOutput.getProductPrice();
        productIcon = productInfoOutput.getProductIcon();
        return this;
    }

    /**
     * 填充购买详情
     *
     * @param detailForm
     * @return
     */
    public OrderDetail fillByDetailForm(OrderDetailForm detailForm) {
        //填充购买信息
        productId = detailForm.getProductId();
        productQuantity = detailForm.getProductQuantity();
        return this;
    }
}